Attachment
上传定义表结构的xml/tdr/proto文件操作
加表时支持proto文件
请求地址
POST
http://OmsAddress/app/newoms.php/webservice/attachment?app_id=appId&zone_id=zoneId&cmd=10001&ip-type=webservicerest&access-token=AccessTokenVal
url中GET参数说明
字段名称 | 数据类型 | 说明 | 是否为必填字段 | 备注 |
---|---|---|---|---|
app_id | 整型 | 上传文件所属业务id | 否 | 建议指定app_id参数的值,这样使用接口上传的文件在tcaplus oms页面上也可以使用,同时方便查询问题 |
zone_id | 整型 | 上传文件所属游戏区的id | 否 |
POST请求参数说明
字段名称 | 数据类型 | 说明 | 是否为必填字段 | 备注 |
---|---|---|---|---|
filename | 字符串 | 需要上传的文件的名称 | 是 | |
content | 字符串 | 需要上传的文件的内容(上传的文件内容上限为10M) | 是 | |
relative_path | 字符串 | 使用pb文件夹上传时,需要上传文件的相对路径 | 否 | 例如有文件夹结构如下 . ├── main.proto └── common . └── user.proto 上传user.proto文件的时候,relative_path为:common/user.proto 上传main.proto文件的时候,relative_path为:main.proto, 或者为空 |
Data参数
使用json格式表示记录相关信息,示例如下:
{
"filename": "check_modify_generic_table.xml",
"content": "<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"yes\" ?> <metalib name=\"table_test\" tagsetversion=\"1\" version=\"1\"><struct name=\"test_table_generic_modify\" version=\"1\" splittablekey=\"gameid\" primarykey=\"gameid,itemid,name\"><entry name=\"gameid\" type=\"uint\" /><entry name=\"itemid\" type=\"uint\" /><entry name=\"name\" type=\"string\" size=\"250\" /><entry name=\"typeid\" type=\"uint8\"/><entry name=\"Data\" type=\"tinyuint\" defaultvalue=\"9\"/><entry name=\"uname\" type=\"string\" size=\"5\" defaultvalue=\"ab\"/><index name=\"index1\" column=\"gameid\" /></struct></metalib>"
}
上传proto文件示例:
{
"filename": "test_table.proto",
"content": "syntax = \"proto3\";package myTcaplusTable;import \"tcaplusservice.optionv1.proto\;"
}
返回语法
返回参数说明
字段名称 | 数据类型 | 说明 | 备注 |
---|---|---|---|
id | 整型 | 上传的文件的id,“3.5.2 申请(tdr/xml)文件加表”、申请修改表时需要使用此值 | |
file_name | 字符串 | 上传的文件名称 | |
file_size | 字符串 | 上传的文件大小(B) | |
file_ext | 字符串 | 上传的文件后缀 |
请求示例
通过 curl 方法发起请求
命令中的参数请参考本页中的“POST请求参数说明”,access-token的获取方法详见:获取access-token
curl -H "Content-type: application/json" -X "POST" -d '{
"filename": "check_modify_generic_table.xml",
"content": "<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"yes\" ?>"
}' 'http://omsaddress/app/newoms.php/webservice/attachment?app_id=<app_id>&zone_id=<zone_id>&cmd=10001&ip-type=webservicerest&access-token=<access-token>'
返回示例
成功返回示例
http请求的Status=200
{
"id": 99,
"file_name": "check_modify_generic_table",
"file_size": 545,
"file_ext": "xml",
"url": "http://10.123.16.72/app/global/uploadfile/2017/03/02/2017030219481393920952.xml"
}
错误返回
http请求的Status!=200
{
"name": "Unauthorized",
"message": "You are requesting with an invalid credential.",
"code": 0,
"status": 401,
"type": "yii\\web UnauthorizedHttpException"
}
{
"source_ip": "ip:10.29.89.51 not in whitelist"
}